
import {defineStore} from "pinia";

//创建用户store
export const useUserStore = defineStore('user', {
    state:()=>{
        return{
            userName:"",
            passWord:"",
            id:""
        }
    },
    getters:{
        getUserName:state=>state.userName,
        getPassWord:state=>state.passWord,
        getId:state=>state.id
    },
    actions:{
        setUserName(userName:string){
            this.userName = userName
        },
        setPassWord(passWord:string){
            this.passWord = passWord
        },
        setId(id:number){
            this.id = id
        }
    },
    persist:{
        enabled:true,
        strategies:[
            {
                key:"user",
                storage:localStorage,
                paths:["userName","id"]
            }
        ]
    }

})
